
INCLUDE(CheckIncludeFile)
CHECK_INCLUDE_FILE( malloc.h EX_HAVE_MALLOC_H )

CONFIGURE_FILE(
  ${CMAKE_CURRENT_SOURCE_DIR}/include/exodusII_cfg.h.in
  ${CMAKE_CURRENT_BINARY_DIR}/include/exodusII_cfg.h
  @ONLY IMMEDIATE)

INCLUDE_DIRECTORIES(
  "${CMAKE_CURRENT_SOURCE_DIR}/include"
  "${CMAKE_CURRENT_BINARY_DIR}/include"
  "${NETCDF_INCLUDE_DIR}"
)

SET(cbind_SRCS
   	src/ex_close.c
   	src/ex_conv.c
   	src/ex_copy.c
   	src/ex_create.c
   	src/ex_cvt_nodes_to_sides.c
   	src/ex_err.c
   	src/ex_get_all_times.c
   	src/ex_get_attr.c
   	src/ex_get_attr_names.c
   	src/ex_get_attr_param.c
   	src/ex_get_block.c
   	src/ex_get_block_param.c
   	src/ex_get_cmap_params.c
   	src/ex_get_concat_node_sets.c
   	src/ex_get_concat_sets.c
   	src/ex_get_concat_side_set_node_count.c
   	src/ex_get_concat_side_sets.c
   	src/ex_get_conn.c
   	src/ex_get_coord.c
   	src/ex_get_coord_names.c
   	src/ex_get_coordinate_frames.c
   	src/ex_get_eb_info_global.c
   	src/ex_get_elem_attr.c
   	src/ex_get_elem_attr_names.c
   	src/ex_get_elem_blk_ids.c
   	src/ex_get_elem_block.c
   	src/ex_get_elem_cmap.c
   	src/ex_get_elem_conn.c
   	src/ex_get_elem_map.c
   	src/ex_get_elem_num_map.c
   	src/ex_get_elem_type.c
   	src/ex_get_elem_var.c
   	src/ex_get_elem_var_tab.c
   	src/ex_get_elem_var_time.c
   	src/ex_get_entity_count_per_polyhedra.c
   	src/ex_get_glob_var_time.c
   	src/ex_get_glob_vars.c
   	src/ex_get_id_map.c
   	src/ex_get_ids.c
   	src/ex_get_info.c
   	src/ex_get_init.c
   	src/ex_get_init_ext.c
   	src/ex_get_init_global.c
   	src/ex_get_init_info.c
   	src/ex_get_loadbal_param.c
   	src/ex_get_map.c
   	src/ex_get_map_param.c
   	src/ex_get_n_conn.c
   	src/ex_get_n_coord.c
   	src/ex_get_n_elem_attr.c
   	src/ex_get_n_elem_conn.c
   	src/ex_get_n_elem_num_map.c
   	src/ex_get_n_elem_var.c
   	src/ex_get_n_nodal_var.c
   	src/ex_get_n_node_num_map.c
   	src/ex_get_n_node_set.c
   	src/ex_get_n_node_set_df.c
   	src/ex_get_n_one_attr.c
   	src/ex_get_n_side_set.c
   	src/ex_get_n_side_set_df.c
   	src/ex_get_n_var.c
   	src/ex_get_name.c
   	src/ex_get_names.c
   	src/ex_get_nodal_var.c
   	src/ex_get_nodal_var_time.c
   	src/ex_get_node_cmap.c
   	src/ex_get_node_map.c
   	src/ex_get_node_num_map.c
   	src/ex_get_node_set.c
   	src/ex_get_node_set_dist_fact.c
   	src/ex_get_node_set_ids.c
   	src/ex_get_node_set_param.c
   	src/ex_get_ns_param_global.c
   	src/ex_get_nset_var.c
   	src/ex_get_nset_var_tab.c
   	src/ex_get_num_map.c
   	src/ex_get_object_truth_vector.c
   	src/ex_get_one_attr.c
   	src/ex_get_one_elem_attr.c
   	src/ex_get_partial_elem_map.c
   	src/ex_get_partial_num_map.c
   	src/ex_get_processor_elem_maps.c
   	src/ex_get_processor_node_maps.c
   	src/ex_get_prop.c
   	src/ex_get_prop_array.c
   	src/ex_get_prop_names.c
   	src/ex_get_qa.c
   	src/ex_get_set.c
   	src/ex_get_set_dist_fact.c
   	src/ex_get_set_param.c
   	src/ex_get_side_set.c
   	src/ex_get_side_set_dist_fact.c
   	src/ex_get_side_set_ids.c
   	src/ex_get_side_set_node_count.c
   	src/ex_get_side_set_node_list.c
   	src/ex_get_side_set_node_list_len.c
   	src/ex_get_side_set_param.c
   	src/ex_get_ss_param_global.c
   	src/ex_get_sset_var.c
   	src/ex_get_sset_var_tab.c
   	src/ex_get_time.c
   	src/ex_get_truth_table.c
   	src/ex_get_var.c
   	src/ex_get_var_name.c
   	src/ex_get_var_names.c
   	src/ex_get_var_param.c
   	src/ex_get_var_tab.c
   	src/ex_get_var_time.c
   	src/ex_get_variable_name.c
   	src/ex_get_variable_names.c
   	src/ex_get_variable_param.c
   	src/ex_inquire.c
   	src/ex_ne_util.c
   	src/ex_open.c
   	src/ex_opts.c
   	src/ex_put_all_var_param.c
   	src/ex_put_all_var_param_ext.c
   	src/ex_put_attr.c
   	src/ex_put_attr_names.c
   	src/ex_put_attr_param.c
   	src/ex_put_block.c
   	src/ex_put_block_param.c
   	src/ex_put_cmap_params.c
   	src/ex_put_cmap_params_cc.c
   	src/ex_put_concat_all_blocks.c
   	src/ex_put_concat_elem_block.c
   	src/ex_put_concat_node_sets.c
   	src/ex_put_concat_sets.c
   	src/ex_put_concat_side_sets.c
   	src/ex_put_concat_var_param.c
   	src/ex_put_conn.c
   	src/ex_put_coord.c
   	src/ex_put_coord_names.c
   	src/ex_put_coordinate_frames.c
   	src/ex_put_eb_info_global.c
   	src/ex_put_elem_attr.c
   	src/ex_put_elem_attr_names.c
   	src/ex_put_elem_block.c
   	src/ex_put_elem_cmap.c
   	src/ex_put_elem_conn.c
   	src/ex_put_elem_map.c
   	src/ex_put_elem_num_map.c
   	src/ex_put_elem_var.c
   	src/ex_put_elem_var_slab.c
   	src/ex_put_elem_var_tab.c
   	src/ex_put_entity_count_per_polyhedra.c
   	src/ex_put_glob_vars.c
   	src/ex_put_id_map.c
   	src/ex_put_info.c
   	src/ex_put_init.c
   	src/ex_put_init_ext.c
   	src/ex_put_init_global.c
   	src/ex_put_init_info.c
   	src/ex_put_loadbal_param.c
   	src/ex_put_loadbal_param_cc.c
   	src/ex_put_map.c
   	src/ex_put_map_param.c
   	src/ex_put_n_coord.c
   	src/ex_put_n_elem_attr.c
   	src/ex_put_n_elem_conn.c
   	src/ex_put_n_elem_num_map.c
   	src/ex_put_n_nodal_var.c
   	src/ex_put_n_node_num_map.c
   	src/ex_put_n_node_set.c
   	src/ex_put_n_node_set_df.c
   	src/ex_put_n_one_attr.c
   	src/ex_put_n_side_set.c
   	src/ex_put_n_side_set_df.c
   	src/ex_put_n_var.c
   	src/ex_put_name.c
   	src/ex_put_names.c
   	src/ex_put_nodal_var.c
   	src/ex_put_nodal_var_slab.c
   	src/ex_put_node_cmap.c
   	src/ex_put_node_map.c
   	src/ex_put_node_num_map.c
   	src/ex_put_node_set.c
   	src/ex_put_node_set_dist_fact.c
   	src/ex_put_node_set_param.c
   	src/ex_put_ns_param_global.c
   	src/ex_put_nset_var.c
   	src/ex_put_nset_var_tab.c
   	src/ex_put_num_map.c
   	src/ex_put_one_attr.c
   	src/ex_put_one_elem_attr.c
   	src/ex_put_partial_elem_map.c
   	src/ex_put_partial_id_map.c
   	src/ex_put_partial_num_map.c
   	src/ex_put_partial_set_dist_fact.c
   	src/ex_put_processor_elem_maps.c
   	src/ex_put_processor_node_maps.c
   	src/ex_put_prop.c
   	src/ex_put_prop_array.c
   	src/ex_put_prop_names.c
   	src/ex_put_qa.c
   	src/ex_put_set.c
   	src/ex_put_sets.c
   	src/ex_put_set_dist_fact.c
   	src/ex_put_set_param.c
   	src/ex_put_side_set.c
   	src/ex_put_side_set_dist_fact.c
   	src/ex_put_side_set_param.c
   	src/ex_put_ss_param_global.c
   	src/ex_put_sset_var.c
   	src/ex_put_sset_var_tab.c
   	src/ex_put_time.c
   	src/ex_put_truth_table.c
   	src/ex_put_var.c
   	src/ex_put_var_name.c
   	src/ex_put_var_names.c
   	src/ex_put_var_param.c
   	src/ex_put_var_tab.c
   	src/ex_put_variable_name.c
   	src/ex_put_variable_names.c
   	src/ex_put_variable_param.c
   	src/ex_update.c
   	src/ex_utils.c
)

SET(cbind_HEADERS
  include/exodusII.h
  include/exodusII_int.h
)

IF(APPLE)
  SET_SOURCE_FILES_PROPERTIES(
    src/ex_utils.c
    PROPERTIES
    COMPILE_FLAGS -fno-common)
ENDIF(APPLE)

ADD_LIBRARY(exoIIv2c ${cbind_SRCS})

TARGET_LINK_LIBRARIES(exoIIv2c ${NETCDF_LIBRARY} ${HDF5_LIBRARY} ${HDF5HL_LIBRARY})

IF(MSVC)
  set_target_properties(exoIIv2c PROPERTIES COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
ENDIF(MSVC)

IF(EXODUS_LIBRARY_PROPERTIES)
  SET_TARGET_PROPERTIES(exoIIv2c PROPERTIES ${EXODUS_LIBRARY_PROPERTIES})
ENDIF(EXODUS_LIBRARY_PROPERTIES)

IF(NOT EXODUS_INSTALL_NO_LIBRARIES)
  INSTALL(TARGETS exoIIv2c
    RUNTIME DESTINATION lib COMPONENT Runtime
    LIBRARY DESTINATION lib COMPONENT Runtime
    ARCHIVE DESTINATION lib COMPONENT Development)
  INSTALL(FILES ${cbind_HEADERS} DESTINATION include COMPONENT Development)
ENDIF(NOT EXODUS_INSTALL_NO_LIBRARIES)


INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake)

IF (BUILD_TESTING)
  ENABLE_TESTING()
  SUBDIRS(test)
ENDIF (BUILD_TESTING)

